package com.hdw.med.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hdw.common.vo.PaginationVO;
import com.hdw.med.api.MdMedOdsDwFidService;
import com.hdw.med.bean.model.MdMedOdsDwFid;
import com.hdw.med.mapper.MdMedOdsDwFidMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * mdMedOdsDwFid服务实现类
 * Created by eleven on 2021/11/29.
 */
@Service
@Transactional
public class MdMedOdsDwFidServiceImpl implements MdMedOdsDwFidService {

    private static final Logger LOGGER = LoggerFactory.getLogger(MdMedOdsDwFidServiceImpl.class);

    @Autowired
    private MdMedOdsDwFidMapper mdMedOdsDwFidMapper;

    @Override
    public int insert(MdMedOdsDwFid mdMedOdsDwFid) {
        return mdMedOdsDwFidMapper.insert(mdMedOdsDwFid);
    }

    @Override
    public int insertSelective(MdMedOdsDwFid mdMedOdsDwFid)  {
        return mdMedOdsDwFidMapper.insertSelective(mdMedOdsDwFid);
    }

    @Override
    public int deleteById(Long idOdsDwFid)  {
        return mdMedOdsDwFidMapper.deleteByPrimaryKey(idOdsDwFid);
    }

    @Override
    public int updateByIdSelective(MdMedOdsDwFid mdMedOdsDwFid)  {

        return mdMedOdsDwFidMapper.updateByPrimaryKeySelective(mdMedOdsDwFid);
    }

    @Override
    public int updateById(MdMedOdsDwFid mdMedOdsDwFid)  {
        return mdMedOdsDwFidMapper.updateByPrimaryKey(mdMedOdsDwFid);
    }

    @Override
    public MdMedOdsDwFid getById(Long idOdsDwFid)  {
        return mdMedOdsDwFidMapper.selectByPrimaryKey(idOdsDwFid);
    }

    @Override
    public List<MdMedOdsDwFid> findByModel(MdMedOdsDwFid mdMedOdsDwFid)  {
        return mdMedOdsDwFidMapper.findByModel(mdMedOdsDwFid);
    }

    @Override
    public PaginationVO<MdMedOdsDwFid> findPageByModel(MdMedOdsDwFid mdMedOdsDwFid, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<MdMedOdsDwFid> quesList = mdMedOdsDwFidMapper.findByModel(mdMedOdsDwFid);
        PageInfo<MdMedOdsDwFid> pageInfo = new PageInfo<>(quesList);
        PaginationVO<MdMedOdsDwFid> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }


}
